/*
 * Worker.h
 *
 *  Created on: 31-07-2011
 *      Author: cristian
 */

#ifndef WORKER_H_
#define WORKER_H_

#include <string>
#include <list>

#include "Logger.h"
#include "Observer.h"
#include "Database.h"

class Worker: public Observer {

private:
	std::string nombre;
	std::string descripcion;
	list<Observer*> observers;
	Database* database;
	int run;
	pthread_t* thread;
	pthread_attr_t* attr;
public:

	Logger* logger;
    pthread_attr_t *getAttr() const;
    void setAttr(pthread_attr_t *attr);
    pthread_t* getThread() const;

	int getRun() const;
	void setRun(int run);
	Worker(std::string nombre, std::string descripcion);
	virtual ~Worker();
	std::string getDescripcion() const;
	std::string getNombre() const;
	void setDescripcion(std::string descripcion);
	void setNombre(std::string nombre);
	void addObserver(Observer* observer);
	void trace();
	void* work(void* arg);
	static void* start(void* arg);
	void stop();
	void updateObservers();
	void update();

};

#endif /* WORKER_H_ */
